<template>
  <div
    class="userLayout"
    :style="{background: backgroundImage.backgroundImage}"
  >
    <div class="logoTop" />
    <!--<div class="byDPI"></div>-->
    <div
      class="bgLayout"
      :style="{background: backgroundImage.backgroundImage}"
      :class="{bgLayoutHover : bgLayoutStatus}"
    />
    <div
      class="userContent"
      @mouseleave="bgLayoutStatus=false"
      @mouseenter="bgLayoutStatus=true"
    >
      <div class="userBox">
        <!-- <div class="title">
                    <span>企业级项目智慧管控平台</span>
                </div> -->
        <!--<div class="userTitle">-->
        <!--&lt;!&ndash;<img src="~@/assets/user/logo.png" class="logo" alt="logo" />&ndash;&gt;-->
        <!--<span>登录</span>-->
        <!--</div>-->
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
import { deviceMixin } from '@/store/device-mixin'
import allBackgroundImages from '@/assets/public/loginRandomBg'

export default {
  name: 'UserLayout',
  mixins: [deviceMixin],
  data() {
    return {
      allBackgroundImages,
      bgLayoutStatus: false
    }
  },
  mounted() {
    document.body.classList.add('userLayout')
  },
  beforeDestroy() {
    document.body.classList.remove('userLayout')
  },
  computed: {
    backgroundImage() {
      // 根据背景图数组的长度随机选择索引
      const randIndex = Math.floor(Math.random() * this.allBackgroundImages.length)
      return {
        // 获取对应的图片资源并将其设置到`background-image`属性上
        backgroundImage: `url(${this.allBackgroundImages[randIndex]}) center center / cover no-repeat`
      }
    }
  }
}
</script>

<style lang="less" scoped>
/*****
    第三版登录
    *****/
.userLayout {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: var(--heightVh);
  width: var(--widthVw);
  overflow: hidden;
  /*  滤镜  */
  // filter: grayscale(100%);
  // -moz-filter: grayscale(100%);
  // -ms-filter: grayscale(100%);
  // -o-filter: grayscale(100%);
  // filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
  // -webkit-filter: grayscale(100%);
  /*  滤镜  */
  .bgLayout {
    position: absolute;
    left: 0;
    top: 0;
    height: var(--heightVh);
    width: var(--widthVw);
    overflow: hidden;
    z-index: 1;
    overflow: hidden;
    background-size: cover;
    transition: filter 1.5s, transform 1.5s;
    -webkit-transition: filter 1.5s, transform 1.5s; /* Safari */
    -webkit-transition: filter 1.5s, transform 1.5s; /* Safari */
    -moz-transition: filter 1.5s, transform 1.5s; /* Safari */
    -ms-transition: filter 1.5s, transform 1.5s; /* Safari */
  }

  .bgLayoutHover {
    filter: blur(5px);
    -webkit-filter: blur(5px);
    -moz-filter: blur(5px);
    -o-filter: blur(5px);
    -ms-filter: blur(5px);
    transform: scale(1.05);
    -webkit-transform: scale(1.05);
    -moz-transform: scale(1.05);
    -o-transform: scale(1.05);
    box-shadow: none;
  }

  .userContent {
    position: relative;
    z-index: 10;

    .userBox {
      position: relative;
      padding: 50px 40px 0;
      width: 460px;
      height: 555px;
      background-color: rgba(0, 0, 0, 0.65);
      border-radius: 8px;
      z-index: 10;

      .title {
        /*display: flex;*/
        /*flex-direction: column;*/
        text-align: center;
        margin-bottom: 25px;

        span {
          margin-bottom: 0;
          font-weight: 500;
          font-size: 34px;
          color: #ffffff;
          /*@media screen and (max-width: 1680px) {*/
          /*font-size: 40px;*/
          /*}*/
          /*@media screen and (max-width: 1366px) {*/
          /*font-size: 30px;*/
          /*}*/
        }
      }

      .userTitle {
        font-size: 24px;
        color: #ffffff;
        font-weight: 100;
        margin-bottom: 20px;
      }
    }
  }
}

.logoTop {
  position: absolute;
  top: 45px;
  left: 45px;
  width: 644px;
  height: 74px;
  background: url('~@/assets/user/login/logo.png') no-repeat 100% 100%;
  z-index: 9;
}

.byDPI {
  position: absolute;
  bottom: 45px;
  right: 45px;
  width: 96px;
  height: 27px;
  background: url('~@/assets/user/login/byDPI.png') no-repeat 100% 100%;
  z-index: 9;
}

/****第二版样式
  .userLayout {
    position: relative;
    // background: #f0f2f5 url(~@/assets/userBg.jpg) no-repeat 100%;
    background: url('~@/assets/user/bg-left.png') no-repeat 90% 100%;
    height: 100vh;
    // width: 100%;
    // min-width: 1000px;
    width: 100vw;
    overflow: hidden;
  }
  .bg-right {
    position: absolute;
    top: 0;
    right: 0;
    width: 56%;
    height: 100%;
    background: url('~@/assets/user/bg-right.png') no-repeat;
    background-size: 100% 100%;
  }
  .userBox {
    position: absolute;
    top: 0;
    left: 0;
    width: 44%;
    height: 100%;
  }
  .userBox {
    padding: 5% 7% 0 5%;
    .title {
      display: flex;
      flex-direction: column;
      span {
        margin-bottom: 0;
        font-weight: bold;
        font-size: 48px;
        color: #000000;
        @media screen and (max-width: 1680px) {
          font-size: 40px;
        }
        @media screen and (max-width: 1366px) {
          font-size: 30px;
        }
      }
    }
  }
  .logo {
    margin-right: 10px;
    object-fit: contain;
    width: 42px;
    height: 42px;
    @media screen and (max-width: 1680px) {
      margin-right: 5px;
      width: 30px;
      height: 30px;
    }
    @media screen and (max-width: 1366px) {
      width: 28px;
      height: 28px;
    }
  }

  .userTitle {
    font-size: 40px;
    display: flex;
    align-items: center;
    padding-top: 50px;
    padding-bottom: 10px;
    @media screen and (max-width: 1680px) {
      font-size: 30px;
      padding-top: 35px;
    }
    @media screen and (max-width: 1366px) {
      font-size: 24px;
      padding-top: 30px;
    }
  }*/
</style>
